package com._520it.crm.web.controller;


import com._520it.crm.domain.AuditInfo;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.AuditInfoQueryObject;
import com._520it.crm.service.IAuditInfoService;
import com._520it.crm.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/auditInfo")
public class AuditInfoController {
    @Autowired
    private IAuditInfoService auditInfoService;


    @RequestMapping("")
    public String index(){
        return "auditInfo";
    }

    @RequestMapping("/list")
    @ResponseBody
    public PageResult list(AuditInfoQueryObject qo){
        PageResult result = null;
        result = auditInfoService.query(qo);
        return result;
    }

    //审核通过
    @RequestMapping("/pass")
    @ResponseBody
    public AjaxResult pass(AuditInfo info){
        AjaxResult result = null;
        try {
            auditInfoService.updateByPrimaryKey(info);
            String batchNumber = auditInfoService.queryBatchNumber(info.getId());
            result = new AjaxResult("批单号:"+batchNumber);
        }catch (Exception e){
            e.printStackTrace();
            result = new AjaxResult(false,"操作失败");
        }
        return result;
    }



}
